/**
 * 
 */
package com.tien.service.impl;

import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.tien.dao.TestDao;
import com.tien.model.Admins;
import com.tien.model.Asset;
import com.tien.model.User;
import com.tien.model.rss.LemonFeed;
import com.tien.service.TestService;

/**
 * @author tien
 * 
 */
@Service
public class TestServiceImpl implements TestService {
	private static final Log logger = LogFactory.getLog(TestServiceImpl.class);
	@Autowired
	private TestDao testDao;

	@Override
	public String getData() {
		return testDao.getRealData();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.tien.service.TestService#getAssets()
	 */
	@Override
	public List<Asset> getAssets(String accountId, int start, int limit) {
		// TODO Auto-generated method stub
		logger.info(" accountId : " + accountId + " start:" + start + " limit:"
				+ limit);
		return testDao.getAssets(accountId, start, limit);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.tien.service.TestService#getAssertsCount()
	 */
	@Override
	public int getAssertsCount(String accountId) {
		// TODO Auto-generated method stub
		return testDao.getAssertsCount(accountId);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.tien.service.TestService#getAssets(int, int)
	 */
	@Override
	public List<Admins> getAdmins(int start, int limit) {
		// TODO Auto-generated method stub
		return testDao.getAssets(start, limit);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.tien.service.TestService#getAdminsCount()
	 */
	@Override
	public int getAdminsCount() {
		return testDao.getAdminsCount();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.tien.service.TestService#getLemonFeedList(java.lang.String)
	 */
	@Override
	public List<LemonFeed> getLemonFeedList(String userId) {
		// TODO Auto-generated method stub
		return testDao.getLemonFeedList(userId);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.tien.service.TestService#saveLemonFeed(java.lang.String)
	 */
	@Override
	public int saveLemonFeed(Map<String, String> params) {
		// TODO Auto-generated method stub
		LemonFeed lemonFeed = new LemonFeed();
		lemonFeed.setFeedType(params.get("feedType"));
		lemonFeed.setTitle(params.get("title"));
		lemonFeed.setLink(params.get("link"));
		lemonFeed.setDescription(params.get("description"));
		lemonFeed.setUserId(params.get("userId"));
		return testDao.saveLemonFeed(lemonFeed);
	}

	@Override
	public void deleteLemonFeed(Integer id) {
		// TODO Auto-generated method stub
		testDao.deleteLemonFeed(id);
	}

	@Override
	public void saveTestAopTransactions() {
		// for successfully test
		/*
		 * User user1 = new User("username1", "password1", "1", "descn", 1,
		 * "descn"); User user2 = new User("username1", "password2", "2",
		 * "descn", 2, "descn"); testDao.saveUser(user1);
		 * 
		 * testDao.saveUser(user2);
		 */
		// for fail test
//		User user1 = new User("username3", "password3", "3", "descn", 3,
//				"descn");
//		User user2 = new User("username4", "password4", "descn", "descn");
//		testDao.saveUser(user1);
//		testDao.saveUser(user2);

	}

}
